﻿#ifndef ConvertString_h__2013_8_29__21_20
#define ConvertString_h__2013_8_29__21_20

#include "df.h"

namespace df
{
	template<typename IT>
	inline void StrToVar(const df::CC & str,IT & var, typename DigitType<IT>::Type * = nullptr)
	{
		StringToDigit(str, var);
	}

	template<class T>
	void StrToVar(const df::CC &,T & , typename DigitType<T>::No *  = nullptr)
	{
		static_assert(sizeof(T) != sizeof(T), "String can not convert to this var");
	}

	inline void StrToVar(const df::CC & str,float & var)
	{
		StringToDigit(str, var);
	}

	inline void StrToVar(const df::CC & str,double & var)
	{
		StringToDigit(str, var);
	}


	inline void StrToVar(const df::CC & str,String & var)
	{
		var.clear();
		var << str;
	}




	//////////////////////////////////////////////////////////////////////////



	inline void VarToStr(const df::CC & var,String & str)
	{
		str.clear();
		str << var;
	}

	inline void VarToStr(const String & var, String & str)
	{
		str=var;
	}

	inline void VarToStr(float var, String & str)
	{
		str.clear();
		str << var;
	}

	inline void VarToStr(double var, String & str)
	{
		str.clear();
		str << var;
	}

	template<typename IT>
	inline void VarToStr(IT var, String & str, typename DigitType<IT>::Type * = nullptr)
	{
		str.clear();
		str << var;
	}

	template<class T>
	void VarToStr(T , String &, typename DigitType<T>::No * = nullptr)
	{
		static_assert(sizeof(T) != sizeof(T), " this var can not convert to String");
	}
}

#endif // ConvertString_h__2013_8_29__21_20
